<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script type="module">
            import { reactive, effect, ref, computed, toRefs } from "./reactivity/index.js";

            // const product = reactive({
            //     name: 'iphone',
            //     price: 5000,
            //     count: 3
            // })
            // const price = ref(5000)
            // const count = ref(3)
            function getProduct() {
                const product = reactive({
                    name: "iphone",
                    price: 5000,
                    count: 3,
                });
                return toRefs(product);
            }
            const { price, count } = getProduct();
            console.log(price);
            // let total = 0
            let total = computed(() => {
                return price.value * count.value;
            });
            // effect(() => {
            //     // total = product.price * product.count
            //     total = price.value * count.value
            // })
            // console.log(total);
            console.log(total.value);
            // product.price = 4000
            price.value = 4000;
            // console.log(total);
            console.log(total.value);
            // product.count = 2
            count.value = 2;
            // console.log(total);
            console.log(total.value);
        </script>
    </body>
</html>
